<template>
    <el-main>
      <div>
        <h1>租房分期</h1>
      </div>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getStageList"></right-toolbar>
      <el-table v-loading="loading" :data="stagetList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="产品名称" align="center" prop="jrProductName" />
        <el-table-column label="资金提供方" align="center" prop="companyName" />
        <el-table-column label="分期期限(-1表示无限期)" align="center" prop="instalmentPeriod" />
        <el-table-column label="授信额度(单位：%，比如80%，存的是80)" align="center" prop="creditLine" />
        <el-table-column label="还款方式" align="center" prop="repaymentType">
          <template slot-scope="scope">
            <span v-if="scope.row.repaymentType==1">
              {{"按月还款"}}
            </span>
            <span v-if="scope.row.repaymentType==2">
              {{"按季还款"}}
            </span>
            <span v-if="scope.row.repaymentType==3">
              {{"按租约周期支付"}}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="银行名称" align="center" prop="bankName" />
        <el-table-column label="状态" align="center" prop="applyState">
          <template slot-scope="scope">
            <span v-if="scope.row.applyState==0">
              {{"待审核"}}
            </span>
            <span v-if="scope.row.applyState==2">
              {{"驳回"}}
            </span>
          </template>
        </el-table-column>

        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleAdd(scope.row,0)"
              v-hasPermi="['system:applyState:edit']"
            >审核</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:applyState:remove']"
            >驳回</el-button>
          </template>
        </el-table-column>
      </el-table>
<!--      <pagination-->
<!--        v-show="total1>10"-->
<!--        :total="total1"-->
<!--        :page.sync="queryParams1.pageNum"-->
<!--        :limit.sync="queryParams1.pageSize"-->
<!--        @pagination="getStageList"-->
<!--      />-->

      <div>
        <h1>收房贷</h1>
      </div>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getCollectList"></right-toolbar>
      <el-table v-loading="loading" :data="collectList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="产品名称" align="center" prop="jrProductName" />
        <el-table-column label="资金提供方" align="center" prop="companyName" />
        <el-table-column label="分期期限(-1表示无限期)" align="center" prop="instalmentPeriod" />
        <el-table-column label="授信额度(单位：%，比如80%，存的是80)" align="center" prop="creditLine" />
        <el-table-column label="还款方" align="center" prop="repaymentType">
          <template slot-scope="scope">
            <span v-if="scope.row.repaymentType==1">
              {{"按月还款"}}
            </span>
            <span v-if="scope.row.repaymentType==2">
              {{"按季还款"}}
            </span>
            <span v-if="scope.row.repaymentType==3">
              {{"按租约周期支付"}}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="银行名称" align="center" prop="bankName" />
        <el-table-column label="状态" align="center" prop="applyState">
          <template slot-scope="scope">
            <span v-if="scope.row.applyState==0">
              {{"待审核"}}
            </span>
            <span v-if="scope.row.applyState==2">
              {{"驳回"}}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleAdd(scope.row,0)"
              v-hasPermi="['system:applyState:edit']"
            >审核</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:applyState:remove']"
            >驳回</el-button>
          </template>
        </el-table-column>
      </el-table>
<!--      <pagination-->
<!--        v-show="total2>0"-->
<!--        :total="total2"-->
<!--        :page.sync="queryParams2.pageNum"-->
<!--        :limit.sync="queryParams2.pageSize"-->
<!--        @pagination="getCollectList"-->
<!--      />-->

      <div>
        <h1>应收租约保理</h1>
      </div>
      <el-table v-loading="loading" :data="leaseList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="产品名称" align="center" prop="jrProductName" />
        <el-table-column label="资金提供方" align="center" prop="companyName" />
        <el-table-column label="分期期限(-1表示无限期)" align="center" prop="instalmentPeriod" />
        <el-table-column label="授信额度(单位：%，比如80%，存的是80)" align="center" prop="creditLine" />
        <el-table-column label="还款方" align="center" prop="repaymentType">
          <template slot-scope="scope">
            <span v-if="scope.row.repaymentType==1">
              {{"按月还款"}}
            </span>
            <span v-if="scope.row.repaymentType==2">
              {{"按季还款"}}
            </span>
            <span v-if="scope.row.repaymentType==3">
              {{"按租约周期支付"}}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="银行名称" align="center" prop="bankName" />
        <el-table-column label="状态" align="center" prop="applyState">
          <template slot-scope="scope">
            <span v-if="scope.row.applyState==0">
              {{"待审核"}}
            </span>
            <span v-if="scope.row.applyState==2">
              {{"驳回"}}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleAdd(scope.row)"
              v-hasPermi="['system:applyState:edit']"
            >审核</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:applyState:remove']"
            >驳回</el-button>
          </template>
        </el-table-column>
      </el-table>
<!--      <pagination-->
<!--        v-show="total3>0"-->
<!--        :total="total3"-->
<!--        :page.sync="queryParams3.pageNum"-->
<!--        :limit.sync="queryParams3.pageSize"-->
<!--        @pagination="getLeaseList"-->
<!--      />-->

    </el-main>

</template>

<script>
import { getappstate,listProduct,getProduct} from "@/api/financial/applyState";

export default {
  name: "Product",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total1: 0,
      total2:0,
      total3:0,
      // 【请填写功能名称】表格数据
      stagetList: [],
      collectList: [],
      leaseList: [],

      // 是否显示弹出层
      open: false,
      // 查询参数
      //分期
      queryParams1: {
        jrProductType: null,
      },
      //收房贷
      queryParams2: {
        jrProductType: null,
      },
      //保理
      queryParams3: {
        jrProductType: null,
      },
    };
  },


  created() {
    this.getStageList();
    this.getCollectList();
    this.getLeaseList();
  },


  methods: {
    /** 查询【请填写功能名称】列表 */
    getStageList() {
      this.loading = true;
      this.queryParams1.jrProductType = 1;
      listProduct(this.queryParams1).then(response => {
        this.stagetList = response.data;
        // this.total1= response.data.total;
        this.loading = false;
      });
    },
    getCollectList() {
      this.loading = true;
      this.queryParams2.jrProductType = 2;
      listProduct(this.queryParams2).then(response => {
        this.collectList = response.data;
        // this.total2= response.data.total;
        this.loading = false;
      });
    },
    getLeaseList() {
      this.loading = true;
      this.queryParams3.jrProductType = 3;
      listProduct(this.queryParams3).then(response => {
        this.leaseList = response.data;
        // this.total3= response.data.total;
        this.loading = false;
      });
    },

    // this.resetForm("form"){};

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 审核按钮操作 */
    handleAdd(val) {
     getappstate(val.id).then(res=>{
      this.$message.success(res.data);
       this.getStageList();
       this.getCollectList();
       this.getLeaseList();
     });
    },
    /** 驳回按钮操作 */
    handleDelete(row) {
      getProduct(row.id).then(response => {
        this.$message.success(response.data);
        this.getStageList();
        this.getCollectList();
        this.getLeaseList();
      });
    },
  }
}

</script>
